Reference
  Area\Util.txt
  Util\Audio.txt
  Util\Party.txt
  Area\Service.txt
  Util\CommonDialog.txt
End Reference

Procedure Main(startAt)

  Dim ac = Nothing

  RegisterCommonEventHandlers()

  SetZoneOfTown(48, 48, 1, 1, 46, 46, ExitArea_Enter)

  ac = AddActor_MTStopped("EqShopper", 22, 28, 0, [A_Man], ActorMotion.Down, Nothing)
  ac = AddStaticActor("EqShopperEve", 22, 29, 10, [A_Null], EqShopperEve_Contact)

  ac = AddActor_MTStopped("MgShopper", 24, 28, 0, [A_OldMan], ActorMotion.Down, Nothing)
  ac = AddStaticActor("MgShopperEve", 24, 29, 10, [A_Null], MgShopperEve_Contact)

  ac = AddActor_MTStopped("GdShopper", 17, 17, 0, [A_Woman], ActorMotion.Down, Nothing)
  ac = AddStaticActor("GdShopperEve", 17, 18, 10, [A_Null], GdShopperEve_Contact)

  ac = AddActor_MTStopped("InnFront", 15, 17, 0, [A_Man], ActorMotion.Down, Nothing)
  ac = AddStaticActor("InnFrontEve", 15, 18, 10, [A_Null], InnFrontEve_Contact)
  
  ac = AddActor_MTZonedRandom("Towner1", 6, 6, 0, _
    3, 4, 0, 9, 8, 0, [A_Man], Towner1_Contact)
  
  ac = AddActor_MTZonedRandom("Towner2", 29, 6, 0, _
    26, 4, 0, 32, 8, 0, [A_Woman], Towner2_Contact)
  
  ac = AddActor_MTZonedRandom("Towner3", 6, 17, 0, _
    3, 15, 0, 9, 19, 0, [A_OldMan], Towner3_Contact)
  
  If TestFlag("WestEvo") AndAlso Not TestFlag("Medrod_1") Then
    ac = AddActor_MTStopped("King", 22, 16, 0, [A_Father], ActorMotion.Down, King_Contact)
    ac = AddActor_MTStopped("GuardMan1", 21, 16, 0, [A_Soldier], ActorMotion.Down, GuardMan1_Contact)
    ac = AddActor_MTStopped("GuardMan2", 23, 16, 0, [A_Soldier], ActorMotion.Down, GuardMan2_Contact)
  End If
  
  DoInsideWarp(startAt, SetEntranceEx({12, 1, 0}, {12, 46, 0}, {1, 35, 0}, {46, 23, 0}), False)
  
  ChangeBGM(Music.Town)
  PutAreaNameLabel()

  NotifyEntered()
  Idle(ProcessInput)
  NotifyExiting()

End Procedure

Procedure ExitArea_Enter()
  BeginOutsideWarp([Field], GetAreaObject().Tag)
End Procedure

Procedure EqShopperEve_Contact()
  DoShop({[BastardSword], [Katana], [SteelArmor], [TitanArmor], [SteelShield], [TitanShield], [SteelHelmet], [TitanHelmet]})
End Procedure

Procedure MgShopperEve_Contact()
  DoMagicShop({[HealAll1], [Revive1], [Elec2], [StrUp], [StrDown], [ColdDPUp], [Heal3], [Fire3], [IntUp], [IntDown], [Berserk], [FireDPUp]})
End Procedure

Procedure GdShopperEve_Contact()
  DoShop({[Heal_T1], [Heal_T2], [CureAll_T], [Revive_T]})
End Procedure

Procedure InnFrontEve_Contact()
  DoInn(150)
End Procedure

Procedure King_Contact()
  Dim p_name = [TheHero].Name + "："
  Dim q_name = "王："
  Dim r_name = "近衛兵："
  If TestFlag("Munalo_1") Then
    DoMsg(q_name, "頼んだぞ　" + [TheHero].Name + "よ！")
  Else
    DoMsg(q_name, "ああ　私の城が……")
    DoMsg(p_name, "いったいどうなされたのですか？")
    DoMsg(q_name, "城の西に古い塔があるのだが", _
      "そこから突然　多くのモンスターがやってきて", _
      "城をおそったのだ", _
      "もちろん我が兵も果敢に戦ってくれたが", _
      "どうも城の周りにいるやつらとは違うようなのだ", _
      "強かった……", _
      "それでやむを得ず　全兵に脱出を指示したのだ")
    DoMsg(p_name, "奪還しに行きましょう")
    DoMsg(q_name, "そうしたい！　が　どうすれば勝てる？", _
      "何か作戦でもあるのか")
    DoMsg(p_name, "敵軍の将を叩けば　残りは逃げるはずです", _
      "私がなんとかしますから", _
      "どうか後方支援をお願いします")
    DoMsg(q_name, "しかしなあ　兵力も僅か", _
      "第一　お前はそんなに強いのか")
    Sleep(500)
    LetActorTurn(GetActor("GuardMan1"), Direction.Right)
    DoMsg(r_name, "陛下　よろしいでしょうか")
    DoMsg(q_name, "なんだ")
    DoMsg(r_name, "私は先ほどから感じているのです", _
      "この者からあふれ出す強い闘気を", _
      "どうやら　只者ではないようです")
    DoMsg(q_name, "そうなのか？")
    DoMsg(r_name, "今ムナロの町を守っている我々の兵も", _
      "いずれ限界の時が来るでしょう", _
      "一か八か　この者に賭けてみてはいかがかと")
    LetActorTurn(GetActor("GuardMan1"), Direction.Down)
    DoMsg(q_name, "ううむ　確かにそうだな", _
      "わかった　私も覚悟を決めよう")
    Sleep(500)
    DoMsg(q_name, "まだ名を聞いていなかったな", _
      "何と申すのだ")
    DoMsg(p_name, [TheHero].Name + "と申します")
    DoMsg(q_name, [TheHero].Name + "か", _
      "私はお前に賭けてみようと思う", _
      "我が兵が敵数を減らしている間に", _
      "奴らの中枢を探し出し　倒すのだ！", _
      "頼んだぞ")
    SetFlag("Munalo_1")
  End If
End Procedure

Procedure GuardMan1_Contact()
  DoMsg("メドロッド城はモンスターの大群に襲われ", _
    "陥落してしまった")
End Procedure

Procedure GuardMan2_Contact()
  DoMsg("この命にかえても　国王陛下をお守りする")
End Procedure

Procedure Towner1_Contact()
  DoMsg("ずっと北西の砂漠の近くに", _
    "メドロッド城がある", _
    "そこからさらに北へ行けば", _
    "ピネマ鉱山があるぞ")
End Procedure

Procedure Towner2_Contact()
  DoMsg("町の外は怪物ばかりで", _
    "出かけるにも命がけよ")
End Procedure

Procedure Towner3_Contact()
  DoMsg("神はこの世界をお造りになられる前に", _
    "まず言葉をお造りになったのじゃ")
  Sleep(500)
  DoMsg("何の意味か分からぬ？", _
    "まあ　お気になさるな", _
    "プレイには関係ない事じゃて")
End Procedure
